package com.ruoyi.test.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.test.domain.dto.TestDTO;
import com.ruoyi.test.domain.entity.Test;
import com.ruoyi.test.mapper.TestMapper;
import com.ruoyi.test.service.ITestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * 测试信息 服务实现类
 */
@Service
public class ITestServiceImpl
        extends ServiceImpl<TestMapper, Test>
        implements ITestService {

    @Autowired
    private TestMapper testMapper;

    @Override
    public List<Test> selectTestList(TestDTO dto) {
        return testMapper.selectTestList(dto);
    }

    @Override
    public Test selectTestById(Long id) {
        return testMapper.selectTestById(id);
    }

    @Override
    public boolean insertTest(TestDTO dto) {
        Test entity = new Test();
        if (!StringUtils.isBlank(dto.getStudentName())) {
            BeanUtils.copyProperties(dto, entity);
        }
        return save(entity);
    }

    @Override
    public boolean updateTest(TestDTO dto) {
        Test entity = new Test();
        if (!StringUtils.isBlank(dto.getStudentName())) {
            BeanUtils.copyProperties(dto, entity);
        }
        return updateById(entity);
    }

    @Override
    public boolean deleteTestByIds(Long[] ids) {
        return removeByIds(Arrays.asList(ids));
    }
}